using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Web.UI;

namespace OpenFlashChartLib
{
    public class GraphDataValues<T> : List<T>, ICountedRender
    {
        private string _tokenName = "values";
        private int _valueSet = 0;
        private int _numDecimals = 3;

        public GraphDataValues()
        {
        }

        public GraphDataValues(string tokenName)
        {
            _tokenName = tokenName;
        }

        public int ValueSet
        {
            get { return _valueSet; }
            set { _valueSet = value; }
        }

        public virtual string TokenName
        {
            get
            {
                return _tokenName;
            }
        }

        public virtual void Render(HtmlTextWriter writer)
        {
            string name = TokenName;
            if (_valueSet != 0)
                name += "_" + _valueSet;
            writer.Write("&{0}=",name);
            int i = 0;
            foreach (T t in this)
            {
                if (i++ > 0)
                    writer.Write(",");
                writer.Write(Convert.ToString(t, CultureInfo.InvariantCulture));
            }
        }

        #region IValueSetRenderer Members

        public string GraphTypeTocken
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public int NumDecimals
        {
            get { return _numDecimals; }
            set { _numDecimals = value; }
        }

        #endregion
    }
}
